cli: Add git fetch template - #10084
Conversation
03dbe5b to
ec6f78d
Compare
|
|
ec6f78d to
148dcae
Compare
josephlou5
left a comment
There was a problem hiding this comment.
I think you need to update docs/templates.md.
148dcae to
a99e3bb
Compare
| /// https://docs.jj-vcs.dev/latest/templates/ | ||
| #[arg(long, short = 'T')] | ||
| #[arg(add = ArgValueCandidates::new(complete::template_aliases))] | ||
| template: Option<String>, |
There was a problem hiding this comment.
Can we use --config instead? Other commands don't use -T/--template when rendering a template is their primary purpose.
| pub fn commit_fetch_template( | ||
| &self, | ||
| template: Option<&str>, | ||
| ) -> TemplateRenderer<'_, crate::git_util::RefStatus> { |
There was a problem hiding this comment.
nit: Maybe move to git_util? I don't think we need a global helper.
| build(self, diagnostics, build_ctx, property, function) | ||
| } | ||
| #[cfg(feature = "git")] | ||
| CommitTemplatePropertyKind::RefStatus(property) => { |
There was a problem hiding this comment.
Can we introduce a generic diff type for CommitRef or RemoteRef? It should probably support both fetch and push summaries.
There was a problem hiding this comment.
To check I understand, are you saying we want to change RefStatus to something like RefDiff so it'll work with a template for jj git push ?
| type](#operation-type) are available as keywords. For example, | ||
| `current_operation` is equivalent to `self.current_operation()`. | ||
|
|
||
| ### RefStatus keywords |
There was a problem hiding this comment.
This section is unnecessary I think.
| * `.import_status() -> String`: "new" if the ref has just been fetched, | ||
| "deleted" if it's just been deleted, or "updated" for changed refs. | ||
| * `.kind() -> String`: "bookmark" or "tag". | ||
| * `.max_name_width() -> Integer`: the length of the longest `name` in the |
There was a problem hiding this comment.
Please make it clearer that a different value is returned for bookmarks than for tags, and that it only applies to the current jj git fetch command.
|
|
||
| The following methods are defined. | ||
|
|
||
| * `.name() -> String`: bookmark or tag name. |
There was a problem hiding this comment.
Please capitalize these sentences if they're not quoted values ("bookmark" → "Bookmark", "the length" → "The length").
`jj git fetch` output can now be templated (`-T`), rather than the previous `RefStatus::output()`. Each ref is exposed as a `RefStatus` type. `RefStatus` has the usual methods, along with `max_name_width` (width of the longest name in a group - bookmarks/tags), so columns can be aligned. A `templates.git_fetch` template has been added, which preserves the original aligned format. Closes jj-vcs#9311
a99e3bb to
2c2d586
Compare
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)how it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.